package com.cy.train.business.controller;

import cn.hutool.core.util.ObjectUtil;
import com.cy.train.business.req.DailyTrainTicketQueryReq;
import com.cy.train.business.resp.DailyTrainTicketQueryResp;
import com.cy.train.business.service.DailyTrainTicketService;
import com.cy.train.common.resp.CommonResp;
import com.cy.train.common.resp.PageResp;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/daily-train-ticket")
public class DailyTrainTicketController {
    @Autowired
    private DailyTrainTicketService dailyTrainTicketService;
    @GetMapping("/query-list")
    public CommonResp<PageResp> register(@Valid DailyTrainTicketQueryReq req) {
        if(ObjectUtil.isNull(req)) {
            req = new DailyTrainTicketQueryReq();
        }
        PageResp<DailyTrainTicketQueryResp> resp = dailyTrainTicketService.queryList(req);
        return new CommonResp<>(resp);
    }
}